package com.husk.leetcode.basic;

import java.util.*;

/**
 * <p>
 *
 * </p>
 *
 * @author hushunke@sm.vvip-u.com
 * @since 2021/7/5
 */
public class MapTop100 {

    private Map<String, Integer> treeMap = new TreeMap<>();

    public void insertBatch(List<String> list) {
        list.forEach(s -> {
            if (treeMap.containsKey(s)) {
                treeMap.put(s, treeMap.get(s) + 1);
            } else {
                treeMap.put(s, 1);
            }
        });
    }

    public void test() {
        Set<Map.Entry<String, Integer>> set = treeMap.entrySet();
        List<Map.Entry<String, Integer>> list = new ArrayList<>(set);
        Collections.sort(list, (o1, o2) -> o2.getValue().compareTo(o1.getValue()));


    }

}
